package com.ficus.road.maintain.dao;

import com.ficus.road.maintain.core.dao.BaseMongoDao;
import com.ficus.road.maintain.core.model.ZhongHai;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author xiawen yang
 * @date 2021/10/15 下午2:25
 */
@Component
public class ZhongHaiDao extends BaseMongoDao<ZhongHai, String> {

    @Override
    protected String getCollectionName() {
        return "zhonghai_data";
    }

    @Override
    protected void indexOperation() {
        super.getMongoTemplate().indexOps(getCollectionName()).ensureIndex(new Index().on("time_stamp", Sort.Direction.DESC).expire(31, TimeUnit.DAYS));
    }
}
